load("//bazel:mongo_src_rules.bzl", "mongo_cc_library", "mongo_cc_unit_test")

package(default_visibility = ["//visibility:public"])

exports_files(
    glob([
        "*.h",
        "*.cpp",
    ]),
)

mongo_cc_library(
    name = "mongo_process_interface",
    srcs = [
        "mongo_process_interface.cpp",
    ],
    hdrs = [
        "mongo_process_interface.h",
        "//src/mongo/bson:bson_validate.h",
        "//src/mongo/bson:bson_validate_gen",
        "//src/mongo/bson/mutable:const_element.h",
        "//src/mongo/bson/mutable:document.h",
        "//src/mongo/client:authenticate.h",
        "//src/mongo/client:client_api_version_parameters_gen",
        "//src/mongo/client:constants.h",
        "//src/mongo/client:dbclient_base.h",
        "//src/mongo/client:dbclient_cursor.h",
        "//src/mongo/client:hedging_mode_gen",
        "//src/mongo/client:index_spec.h",
        "//src/mongo/client:internal_auth.h",
        "//src/mongo/client:mongo_uri.h",
        "//src/mongo/client:read_preference.h",
        "//src/mongo/client:read_preference_gen",
        "//src/mongo/client:read_preference_validators.h",
        "//src/mongo/client:sasl_client_session.h",
        "//src/mongo/crypto:encryption_fields_gen",
        "//src/mongo/crypto:encryption_fields_validation.h",
        "//src/mongo/crypto:fle_field_schema_gen",
        "//src/mongo/crypto:fle_fields_util.h",
        "//src/mongo/crypto:sha1_block.h",
        "//src/mongo/db:aggregated_index_usage_tracker.h",
        "//src/mongo/db:api_parameters.h",
        "//src/mongo/db:api_parameters_gen",
        "//src/mongo/db:collection_index_usage_tracker.h",
        "//src/mongo/db:collection_type.h",
        "//src/mongo/db:commands.h",
        "//src/mongo/db:dbmessage.h",
        "//src/mongo/db:feature_compatibility_version_parser.h",
        "//src/mongo/db:feature_flag.h",
        "//src/mongo/db:index_names.h",
        "//src/mongo/db:json.h",
        "//src/mongo/db:keypattern.h",
        "//src/mongo/db:multitenancy_gen",
        "//src/mongo/db:namespace_spec_gen",
        "//src/mongo/db:read_concern_support_result.h",
        "//src/mongo/db:request_execution_context.h",
        "//src/mongo/db:resource_yielder.h",
        "//src/mongo/db:shard_id.h",
        "//src/mongo/db:update_index_data.h",
        "//src/mongo/db:vector_clock_gen",
        "//src/mongo/db:write_concern.h",
        "//src/mongo/db/auth:access_checks_gen",
        "//src/mongo/db/auth:auth_types_gen",
        "//src/mongo/db/auth:authorization_manager.h",
        "//src/mongo/db/auth:authorization_router.h",
        "//src/mongo/db/auth:builtin_roles.h",
        "//src/mongo/db/auth:ldap_cumulative_operation_stats.h",
        "//src/mongo/db/auth:ldap_operation_stats.h",
        "//src/mongo/db/auth:privilege_format.h",
        "//src/mongo/db/auth:restriction.h",
        "//src/mongo/db/auth:restriction_set.h",
        "//src/mongo/db/auth:role_name_or_string.h",
        "//src/mongo/db/auth:user.h",
        "//src/mongo/db/auth:user_acquisition_stats.h",
        "//src/mongo/db/auth:user_cache_access_stats.h",
        "//src/mongo/db/catalog:collection_operation_source.h",
        "//src/mongo/db/catalog:collection_options.h",
        "//src/mongo/db/catalog:collection_options_gen",
        "//src/mongo/db/catalog:collection_options_validation.h",
        "//src/mongo/db/catalog/util:partitioned.h",
        "//src/mongo/db/commands:server_status_metric.h",
        "//src/mongo/db/commands:test_commands_enabled.h",
        "//src/mongo/db/concurrency:d_concurrency.h",
        "//src/mongo/db/exec:exec_shard_filter_policy.h",
        "//src/mongo/db/exec:shard_filterer.h",
        "//src/mongo/db/matcher:expression.h",
        "//src/mongo/db/matcher:expression_visitor.h",
        "//src/mongo/db/matcher:match_details.h",
        "//src/mongo/db/matcher:matchable.h",
        "//src/mongo/db/matcher:path.h",
        "//src/mongo/db/pipeline:change_stream_pre_and_post_images_options_gen",
        "//src/mongo/db/pipeline:dependencies.h",
        "//src/mongo/db/pipeline:legacy_runtime_constants_gen",
        "//src/mongo/db/pipeline:lite_parsed_document_source.h",
        "//src/mongo/db/pipeline:sharded_agg_helpers_targeting_policy.h",
        "//src/mongo/db/pipeline:storage_stats_spec_gen",
        "//src/mongo/db/pipeline:variables.h",
        "//src/mongo/db/query:allowed_contexts.h",
        "//src/mongo/db/query:explain_version_validator.h",
        "//src/mongo/db/query:find_command.h",
        "//src/mongo/db/query:find_command_gen",
        "//src/mongo/db/query:hint_parser.h",
        "//src/mongo/db/query:index_hint.h",
        "//src/mongo/db/query:lru_key_value.h",
        "//src/mongo/db/query:partitioned_cache.h",
        "//src/mongo/db/query:query_knob_expressions.h",
        "//src/mongo/db/query:query_knobs_gen",
        "//src/mongo/db/query/client_cursor:generic_cursor.h",
        "//src/mongo/db/query/client_cursor:generic_cursor_gen",
        "//src/mongo/db/query/plan_cache:sbe_plan_cache_on_parameter_change.h",
        "//src/mongo/db/query/query_settings:index_hints_serialization.h",
        "//src/mongo/db/query/query_settings:query_framework_serialization.h",
        "//src/mongo/db/query/query_settings:query_settings_comment.h",
        "//src/mongo/db/query/query_settings:query_settings_gen",
        "//src/mongo/db/query/query_stats:query_stats_on_parameter_change.h",
        "//src/mongo/db/query/util:memory_util.h",
        "//src/mongo/db/query/write_ops:single_write_result_gen",
        "//src/mongo/db/query/write_ops:update_result.h",
        "//src/mongo/db/query/write_ops:write_ops.h",
        "//src/mongo/db/query/write_ops:write_ops_exec.h",
        "//src/mongo/db/query/write_ops:write_ops_exec_util.h",
        "//src/mongo/db/query/write_ops:write_ops_gen",
        "//src/mongo/db/query/write_ops:write_ops_parsers.h",
        "//src/mongo/db/repl:apply_ops_gen",
        "//src/mongo/db/repl:member_config.h",
        "//src/mongo/db/repl:member_config_gen",
        "//src/mongo/db/repl:member_data.h",
        "//src/mongo/db/repl:member_id.h",
        "//src/mongo/db/repl:member_state.h",
        "//src/mongo/db/repl:oplog.h",
        "//src/mongo/db/repl:oplog_constraint_violation_logger.h",
        "//src/mongo/db/repl:oplog_entry.h",
        "//src/mongo/db/repl:oplog_entry_gen",
        "//src/mongo/db/repl:oplog_entry_or_grouped_inserts.h",
        "//src/mongo/db/repl:oplog_entry_serialization.h",
        "//src/mongo/db/repl:optime_base_gen",
        "//src/mongo/db/repl:read_concern_args.h",
        "//src/mongo/db/repl:repl_client_info.h",
        "//src/mongo/db/repl:repl_server_parameters_gen",
        "//src/mongo/db/repl:repl_set_config.h",
        "//src/mongo/db/repl:repl_set_config_gen",
        "//src/mongo/db/repl:repl_set_config_params_gen",
        "//src/mongo/db/repl:repl_set_config_validators.h",
        "//src/mongo/db/repl:repl_set_heartbeat_response.h",
        "//src/mongo/db/repl:repl_set_tag.h",
        "//src/mongo/db/repl:repl_set_write_concern_mode_definitions.h",
        "//src/mongo/db/repl:repl_settings.h",
        "//src/mongo/db/repl:replication_coordinator.h",
        "//src/mongo/db/repl:replication_coordinator_fwd.h",
        "//src/mongo/db/repl:split_horizon.h",
        "//src/mongo/db/repl:split_prepare_session_manager.h",
        "//src/mongo/db/repl:sync_source_selector.h",
        "//src/mongo/db/session:internal_session_pool.h",
        "//src/mongo/db/session:logical_session_cache_gen",
        "//src/mongo/db/storage:backup_block.h",
        "//src/mongo/db/storage:backup_cursor_hooks.h",
        "//src/mongo/db/storage:backup_cursor_state.h",
        "//src/mongo/db/storage:storage_engine_init.h",
        "//src/mongo/db/timeseries:timeseries_gen",
        "//src/mongo/db/timeseries:timeseries_global_options.h",
        "//src/mongo/db/update:document_diff_applier.h",
        "//src/mongo/db/update:document_diff_serialization.h",
        "//src/mongo/executor:connection_metrics.h",
        "//src/mongo/executor:remote_command_request.h",
        "//src/mongo/executor:remote_command_response.h",
        "//src/mongo/executor:task_executor.h",
        "//src/mongo/idl:cluster_server_parameter_gen",
        "//src/mongo/idl:generic_argument.h",
        "//src/mongo/idl:generic_argument_gen",
        "//src/mongo/rpc:get_status_from_command_result.h",
        "//src/mongo/rpc:metadata.h",
        "//src/mongo/rpc:protocol.h",
        "//src/mongo/rpc:reply_builder_interface.h",
        "//src/mongo/rpc:reply_interface.h",
        "//src/mongo/rpc:topology_version_gen",
        "//src/mongo/rpc:unique_message.h",
        "//src/mongo/rpc/metadata:impersonated_user_metadata_gen",
        "//src/mongo/rpc/metadata:oplog_query_metadata.h",
        "//src/mongo/s:chunk.h",
        "//src/mongo/s:chunk_manager.h",
        "//src/mongo/s:chunk_version.h",
        "//src/mongo/s:chunk_version_gen",
        "//src/mongo/s:database_version.h",
        "//src/mongo/s:database_version_base_gen",
        "//src/mongo/s:gossiped_routing_cache_gen",
        "//src/mongo/s:index_version.h",
        "//src/mongo/s:shard_key_pattern.h",
        "//src/mongo/s:shard_version.h",
        "//src/mongo/s:stale_exception.h",
        "//src/mongo/s:type_collection_common_types_gen",
        "//src/mongo/s/catalog:type_chunk.h",
        "//src/mongo/s/catalog:type_chunk_base_gen",
        "//src/mongo/s/catalog:type_chunk_range.h",
        "//src/mongo/s/catalog:type_chunk_range_base_gen",
        "//src/mongo/s/resharding:type_collection_fields_gen",
        "//src/mongo/transport:baton.h",
        "//src/mongo/transport:message_compressor_base.h",
        "//src/mongo/transport:message_compressor_manager.h",
        "//src/mongo/transport:service_executor.h",
        "//src/mongo/transport:ssl_connection_context.h",
        "//src/mongo/transport:transport_layer.h",
        "//src/mongo/util:invalidating_lru_cache.h",
        "//src/mongo/util:lru_cache.h",
        "//src/mongo/util:read_through_cache.h",
        "//src/mongo/util/concurrency:notification.h",
        "//src/mongo/util/concurrency:thread_pool_interface.h",
        "//src/mongo/util/net:sock.h",
        "//src/mongo/util/net:ssl_manager.h",
        "//src/mongo/util/net:ssl_options.h",
        "//src/mongo/util/net/ssl:apple.hpp",
    ],
    header_deps = [
        "//src/mongo/db/concurrency:flow_control_ticketholder",
        "//src/mongo/db/exec/sbe:query_sbe_plan_stats",
    ],
    deps = [
        "//src/mongo:base",
    ],
)

mongo_cc_library(
    name = "common_process_interface",
    srcs = [
        "common_process_interface.cpp",
    ],
    hdrs = [
        "common_process_interface.h",
    ],
    deps = [
        "//src/mongo/db:operation_time_tracker",
        "//src/mongo/db/auth",
        "//src/mongo/db/concurrency:lock_manager",
        "//src/mongo/db/pipeline:field_path",
        "//src/mongo/db/query/client_cursor:generic_cursor",
        "//src/mongo/s:sharding_router_api",
        "//src/mongo/util/concurrency:spin_lock",
    ],
)

mongo_cc_library(
    name = "mongos_process_interface",
    srcs = [
        "mongos_process_interface.cpp",
    ],
    hdrs = [
        "mongos_process_interface.h",
    ],
    deps = [
        ":common_process_interface",
        "//src/mongo/db/pipeline",
        "//src/mongo/db/pipeline:sharded_agg_helpers",
        "//src/mongo/db/session:session_catalog",
        "//src/mongo/s/query/exec:async_results_merger",
        "//src/mongo/s/query/exec:cluster_cursor",
    ],
)

mongo_cc_library(
    name = "mongos_process_interface_factory",
    srcs = [
        "mongos_process_interface_factory.cpp",
    ],
    deps = [
        ":mongos_process_interface",
    ],
)

# This library is the basic mongod functionality, depended on by embedded so
# designed to exclude large components like sharding and networking.
mongo_cc_library(
    name = "mongod_process_interfaces",
    srcs = [
        "common_mongod_process_interface.cpp",
        "non_shardsvr_process_interface.cpp",
        "replica_set_node_process_interface.cpp",
    ],
    hdrs = [
        "common_mongod_process_interface.h",
        "non_shardsvr_process_interface.h",
        "replica_set_node_process_interface.h",
    ],
    deps = [
        ":common_process_interface",
        "//src/mongo/db:collection_index_usage_tracker",
        "//src/mongo/db:dbhelpers",
        "//src/mongo/db:multitenancy",
        "//src/mongo/db:operation_time_tracker",
        "//src/mongo/db:server_feature_flags",
        "//src/mongo/db/catalog:catalog_helpers",
        "//src/mongo/db/catalog:database_holder",
        "//src/mongo/db/concurrency:exception_util",
        "//src/mongo/db/concurrency:flow_control_ticketholder",
        "//src/mongo/db/index_builds:index_builds_coordinator_mongod",
        "//src/mongo/db/pipeline",
        "//src/mongo/db/query/client_cursor",
        "//src/mongo/db/query/write_ops",
        "//src/mongo/db/query/write_ops:write_ops_exec",
        "//src/mongo/db/repl:primary_only_service",
        "//src/mongo/db/s:query_analysis_writer",
        "//src/mongo/db/s:transaction_coordinator",
        "//src/mongo/db/session:session_catalog",
        "//src/mongo/db/stats:top",
        "//src/mongo/db/storage:backup_cursor_hooks",
        "//src/mongo/db/storage:durable_catalog",
        "//src/mongo/db/storage:feature_document_util",
        "//src/mongo/db/timeseries/write_ops:timeseries_write_ops",
        "//src/mongo/db/transaction",
        "//src/mongo/s:query_analysis_sampler",
        "//src/mongo/s:sharding_router_api",
        "//src/mongo/scripting:scripting_common",
    ],
)

mongo_cc_library(
    name = "shardsvr_process_interface",
    srcs = [
        "shardsvr_process_interface.cpp",
    ],
    hdrs = [
        "shardsvr_process_interface.h",
    ],
    deps = [
        ":mongod_process_interfaces",
        "//src/mongo/db:query_exec",
        "//src/mongo/s:sharding_api",
    ],
)

mongo_cc_library(
    name = "mongod_process_interface_factory",
    srcs = [
        "mongod_process_interface_factory.cpp",
    ],
    hdrs = [
        "standalone_process_interface.h",
    ],
    deps = [
        ":mongod_process_interfaces",
        ":mongos_process_interface",
        ":shardsvr_process_interface",
        "//src/mongo/db:shard_role_api",
    ],
)

mongo_cc_unit_test(
    name = "process_interface_test",
    srcs = [
        "mongos_process_interface_test.cpp",
        "shardsvr_process_interface_test.cpp",
        "standalone_process_interface.h",
        "standalone_process_interface_test.cpp",
        "//src/mongo/s/query/exec:sharded_agg_test_fixture.h",
    ],
    tags = ["mongo_unittest_first_group"],
    deps = [
        ":mongos_process_interface",
        ":shardsvr_process_interface",
        "//src/mongo/db:service_context_non_d",
        "//src/mongo/db:service_context_test_fixture",
        "//src/mongo/db:shard_role_api",
        "//src/mongo/db:vector_clock_mongod",
        "//src/mongo/db/auth:authmocks",
        "//src/mongo/db/pipeline:aggregation_context_fixture",
        "//src/mongo/db/query:query_test_service_context",
        "//src/mongo/db/repl:replmocks",
        "//src/mongo/s:sharding_mongos_test_fixture",
    ],
)
